package xinxin.com.IteratorPatternBasic;

import xinxin.com.IteratorPatternBasic.Aggregate.ConcreteAggregate;
import xinxin.com.IteratorPatternBasic.Iterator.ConcreteIterator;
import xinxin.com.IteratorPatternBasic.Iterator.ConcreteIteratorDesc;
import xinxin.com.IteratorPatternBasic.Iterator.Iterator;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/3/29 9:28
 */
public class IteratorPatternBasic {
    public static void main(String[] args) {
        ConcreteAggregate aggregate = new ConcreteAggregate(6);
        aggregate.set(0, "大鸟");
        aggregate.set(1, "小菜");
        aggregate.set(2, "行李");
        aggregate.set(3, "老外");
        aggregate.set(4, "公交内部员工");
        aggregate.set(5, "小偷");

        Iterator iterator = new ConcreteIteratorDesc(aggregate);
        Object object = iterator.First();
        while (!iterator.IsDone()) {
            System.out.println(iterator.CurrentItem() + "请买车票");
            iterator.Next();
        }
    }
}
